//
//  Ball.m

//  Gravity

//

//  Created by GYUNGJIN LEE on 6/9/12.

//  Copyright (c) 2012 i don't belong nowhere. All rights reserved.

//



#import "Ball.h"



@implementation Ball

@synthesize position;

@synthesize velocity;

@synthesize radius;

@synthesize color;

@synthesize bounce;

@synthesize gravity;

@synthesize hold;

@synthesize stopFlying;



- (void)update {
    
    if (hold){
        
        velocity.y-=gravity;
        
        //position.x -= velocity.x;
        
        position.y -= velocity.y;
        
    }else{
        
        velocity.y+=gravity;
        
        //position.x += velocity.x;
        
        position.y += velocity.y;
        
    }
    
        
    if(position.y+radius==330.0){
        stopFlying=YES;
    }
    else{
        stopFlying=NO;
    }
    
    if(position.y + radius > 320.0) {
        
        position.y = 320.0 - radius;
        
    }
    
    else if(position.y - radius < 0.0) {
        
        position.y = radius;
        
        //velocity.y *= -1.0;
        
    }
    
}

@end

